var ExtractTextPlugin = require('extract-text-webpack-plugin');
var dirVars = require('./base/dir-vars.config.js');

const moduleConfig = require('./inherit/module.config.js');
const PROJECT = require('./project.config.js');
moduleConfig.rules.push({
  test: /\.css$/,
  exclude: /node_modules|bootstrap/,
  // loader: ExtractTextPlugin.extract('css?minimize&-autoprefixer!postcss'),
  use: ExtractTextPlugin.extract(
    {use: [
      {
        loader: 'css-loader',
        options: {
          minimize: true,
          '-autoprefixer': true,
        },
      },
      {
        loader: 'postcss-loader',
      },
    ],
      publicPath: '/' + PROJECT.ROOT + '/',
    }),
});

moduleConfig.rules.push({
  test: /\.css$/,
  include: /node_modules|bootstrap/,
  use: ExtractTextPlugin.extract({
    use: 'css-loader',
    publicPath: '/' + PROJECT.ROOT + '/',
  }),
});

moduleConfig.rules.push({
  test: /\.less$/,
  include: [dirVars.srcRootDir, /bootstrap/],
  use: ExtractTextPlugin.extract({
    use: [
      {
        loader: 'css-loader',
        options: {
          minimize: true,
        },
      },
      {
        loader: 'postcss-loader',
      },
      {
        loader: 'less-loader',
      },
    ],
    publicPath: '/' + PROJECT.ROOT + '/',
  }),
});

module.exports = moduleConfig;
